package com.yuanxiao.common.core.utils;

import java.util.regex.Pattern;

/**
 * Created by luozongsheng on 20/12/2016.
 */
public class Regular{

    /**
     * 移动电话
     * @param phone
     * @return
     */
    public static boolean isMobilePhone(String phone){
        if(!Pattern.matches("(\\+\\d+)?1[0123456789]\\d{9}$", phone)){
            return false;
        }
        return true;
    }

    /**
     * 固定电话
     * @param phone
     * @return
     */
    public static boolean isLandline(String phone){
        if(!Pattern.matches("^[0][1-9]{2,3}-[0-9]{5,10}$", phone)){
            return false;
        }
        return true;
    }

    /**
     * 邮箱
     * @param email
     * @return
     */
    public static boolean isEmail(String email){
        if(!Pattern.matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$", email)){
            return false;
        }
        return true;
    }

    /**
     * 身份证
     * @param certNo
     * @return
     */
    public static boolean isIdCardNum(String certNo){
       /* if(!Pattern.matches("^[1-9]\\\\d{7}((0\\\\d)|(1[0-2]))(([0|1|2]\\\\d)|3[0-1])\\\\d{3}$", certNo)
                &&!Pattern.matches("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$", certNo)){
            return false;
        }*/
        return true;
    }

    public static void main(String[] args){
        if (isIdCardNum("532929198708241939")) {
            System.out.print("1");
        }
    }

}
